package com.janko.springbootbase.designmode.singleton;

/**
 * @ClassName Singleton4StaticLock
 * @Description JVM->利用classloder的机制来保证初始化instance时只有一个对象
 * @Author janko
 * @Date 2020/12/11 15:03
 */
public class Singleton4Instance extends BaseSingleton {
    /**
     * 定义一个单例的真正拥有者。
     * 内部静态类 机制解决方案
     */
    private static class SingletonHolder {
        public static Singleton4Instance singleton = new Singleton4Instance();

        public static void m() {
            System.out.println("我这里是具体实现的业务啊");
        }
    }

    private static Singleton4Instance getInstance() {
        return SingletonHolder.singleton;
    }

}
